package com.flyduck.vueshop.search.config;

import com.flyduck.vueshop.common.rabbitmq.constant.SearchRabbitConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: vueshop
 * @description:
 * @author: flyduck
 * @create: 2024-05-25 07:34
 **/
@Configuration
public class SearchRabbitConfig {
    @Bean
    public TopicExchange productSearchExchange(){
        return new TopicExchange(SearchRabbitConstant.PRODUCT_SEARCH_EXCHANGE,true,false);
    }




    public Queue productSearchCreateQueue(){
        return QueueBuilder.durable(SearchRabbitConstant.PRODUCT_SEARCH_CREATE_QUEUE)
                .build();
    }
    @Bean
    public Binding productSearchCreateBinding(){
        return BindingBuilder
                .bind(productSearchCreateQueue())
                .to(productSearchExchange())
                .with(SearchRabbitConstant.PRODUCT_SEARCH_CREATE_KEY);
    }




    @Bean
    public Queue productSearchDeleteQueue(){
        return QueueBuilder.durable(SearchRabbitConstant.PRODUCT_SEARCH_DELETE_QUEUE)
                .build();
    }
    @Bean
    public Binding productSearchDeleteBinding(){
        return BindingBuilder
                .bind(productSearchDeleteQueue())
                .to(productSearchExchange())
                .with(SearchRabbitConstant.PRODUCT_SEARCH_DELETE_KEY);
    }
}
